/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package de.jonasjelten.jcalc.mathExps;

import de.jonasjelten.jcalc.exception.JEvaluationException;
import de.jonasjelten.jcalc.math.JDualNumber;
import de.jonasjelten.jcalc.math.JNumber;

/**
 *
 * @author JJ
 */
public class JFacBounded extends JDualArgMathExp {

    public JFacBounded(JMathExp highlimit, JMathExp lowlimit) {
        super(highlimit, lowlimit);
    }

    @Override
    public JNumber eval() throws JEvaluationException {
        JDualNumber childrenEvaluated = super.evalChildren();
        JNumber res;
        super.jcalc.expgroup.addActive();
        JNumber hlim = childrenEvaluated.getNumber0();
        JNumber llim = childrenEvaluated.getNumber1();
        res = hlim.facultyBounded(llim);

        super.jcalc.expgroup.setInactive();
        return res;
    }

    @Override
    public boolean isTrivial() {
        return true;
    }

    @Override
    public String toString() {
        return "("+super.arg0.toString()+"!/"+super.arg1.toString()+"!)";
    }

}
